

<div id="test_save">
    <form>
        <zrow>

            <zcol :md="6">
                <zinput label="作者" name="author" :ctx="this"/>
            </zcol>

            <zcol :md="6">
                <zinput label="标题" name="title" :ctx="this"/>
            </zcol>
        </zrow>


        <zrow>
            <zcol :md="6">
                <zinput label="缩略图" name="thumb" :ctx="this"/>
            </zcol>

            <zcol :md="6">
                <zinput label="内容" name="content" :ctx="this"/>
            </zcol>
        </zrow>


        <zrow>        </zrow>

        <a @click="submit" class="btn btn-primary">提交</a>
    </form>

</div>

<script>
    new Vue({
        el:'#test_save',
        mounted:function(){
            if(this.editData){
                this.form = this.editData ;
            }
            this.state.status = 'mounted'
        },
        data:{
            state:{
                status:''
            },
            form:{
                author:'',
                title:'',
                thumb:'',
                content:'',
            },
            validate:{
                author:[Va.required],
                title:[Va.required],
                thumb:[Va.required],
                content:[Va.required],
            },
            editData:{!! $data !!}
        },
        methods:{
            submit:function(){

                if(!validateAll(this)){
                    return
                }

                var id = App.url().param('id') || '' ;

                zhttp.post('test/save?id='+id,this.form,function (d) {
                    if(d.code == 0){
                        success('操作成功')
                        //Loader.getDialog('test/save').close()
                        go('test/index')
                    }else{

                    }
                    return false ;
                })
            }
        }
    })
</script>